import pygame;
from settings import Settings;
from ship import Ship;
import game_functions as gf;
from pygame.sprite import Group;


def run_game():
	#初始化游戏并创建一个屏幕对象
	pygame.init();

	ai_settings = Settings();
	
	screen=pygame.display.set_mode((ai_settings.screen_width,ai_settings.screen_height));
	ai_ship = Ship(ai_settings,screen);

	
	bullets = Group();
	aliens = Group();
	
	pygame.display.set_caption("Alien Invasion");
	
	gf.create_fleet(ai_settings,screen,aliens);
	
	#开始游戏的主循环
	while True:
		#坚挺键盘和鼠标事件
		gf.check_events(ai_settings,screen,ai_ship,bullets);
		ai_ship.update();
		gf.update_bullets(bullets);
		
		gf.update_screen(ai_settings,screen,ai_ship,aliens,bullets);
		
run_game();